
package com.one.controller.action;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.one.mycommons.base.BaseController;
import com.one.myservice.entity.Person;
import com.one.myservice.form.PersonForm;
import com.one.myservice.service.IDemoService;


@Controller
@RequestMapping("/default")
public class DefaultController extends BaseController{
	
	@SuppressWarnings("static-access")
	private static Logger log = getLog().getLogger(loginController.class);
	
	@Resource(name = "demoService")
	private IDemoService demoService;
	
	@RequestMapping(value="/index1")
	@ResponseBody
	public Object defaultHandler() throws Exception{
		//处理不匹配的请求		
		PersonForm p = new PersonForm();
		p.setName("chen");
		String[] arr = new String[1];
		arr[0]="chen";
		p.setArray(arr);
		List<Person> result = demoService.findAll(p);
		log.debug("  result : " + result);
		Map<String, Object> map = new HashMap<>();
		map.put("data", result);
		System.out.println(p.getTotle());
		map.put("page", p);
		return map;
	}
	
	@RequestMapping("/test")
	public ModelMap test(HttpServletRequest req, HttpServletResponse res){
		//System.out.println(Class.class.getClass().getResource("/").getPath());
		return new ModelMap();
	}

}

